home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / unix / src / child.asm < prev    next >
Encoding:
Assembly Source File  |  1992-08-14  |  1.8 KB  |  107 lines

  1.     INCLUDE    "utility/tagitem.i"
  2.     INCLUDE    "exec/tasks.i"
  3.     INCLUDE    "exec/ports.i"
  4.  
  5.     XREF    _LVOPutMsg
  6.     XREF    _LVOSystemTagList
  7.     XREF    _LVOFreeMem
  8.     XREF    _LVOFindPort
  9.     XREF    _LVOFindTask
  10.     XREF    _LVOAddHead
  11.     XREF    __startup_port
  12.     XREF    _LinkerDB
  13.     XREF    _us
  14.  
  15.     XDEF    __child_startup
  16.     XDEF    __child_startup_end
  17.  
  18.     csect    text,0,,2,2
  19.  
  20.     XREF    __child_command
  21.     XREF    __child_command_len
  22.     XREF    __child_door_name
  23.     XREF    __child_door_name_len
  24.     XREF    __child_exit
  25.     XREF    _DOSBase
  26.     XREF    _startup_message
  27.     XREF    __child_entry
  28.  
  29. * Code executed by a child process. A new copy is created for each child.
  30.  
  31. __child_startup:
  32.     movem.l    d2-d5/a2-a5,-(a7)
  33.     
  34.     lea    _LinkerDB,a4
  35.     move.l    __child_command(a4),d4
  36.     move.l    __child_command_len(a4),d5
  37.     move.l    __child_exit(a4),a2
  38.     move.l    _DOSBase(a4),a3
  39.     move.l    __child_door_name(a4),a5
  40.     move.l    __child_door_name_len(a4),d3
  41.  
  42. * Arrange for code to be freed on exit
  43.     sub.l    a1,a1
  44.     move.l    4,a6
  45.     jsr    _LVOFindTask(a6)
  46.     move.l    d0,a0
  47.     lea    TC_MEMENTRY(a0),a0
  48.     move.l    __child_entry(a4),a1
  49.     jsr    _LVOAddHead(a6)
  50.     
  51. * Send startup message to parent    
  52.     move.l    4,a6
  53.     move.l    __startup_port,a0
  54.     lea    _startup_message(a4),a1
  55.     jsr    _LVOPutMsg(a6)
  56.  
  57. * From now on, parent may disappear.
  58.  
  59. * Start command
  60.     move.l    a3,a6
  61.     move.l    d4,d1
  62.     lea    notags(pc),a0
  63.     move.l    a0,d2
  64.     jsr    _LVOSystemTagList(a6)
  65. * Prepare result code
  66.     lsl.l    #8,d0
  67.     move.l    d0,24(a2)
  68.  
  69. * Send result to parent if he is still there
  70.     move.l    a5,a1
  71.     move.l    4,a6
  72.     jsr    _LVOFindPort(a6)
  73.     tst.l    d0
  74.     beq.s    noemacs
  75.  
  76.     move.l    d0,a0
  77.     move.l    a2,a1
  78.     jsr    _LVOPutMsg(a6)
  79.     bra.s    exit
  80.  
  81. noemacs:
  82. * Free child_exit
  83.     move.l    a2,a1
  84.     moveq    #0,d0
  85.     move.w    MN_LENGTH(a2),d0
  86.     jsr    _LVOFreeMem(a6)
  87.  
  88. exit:
  89. * Free port name
  90.     move.l    a5,a1
  91.     move.l    d3,d0
  92.     jsr    _LVOFreeMem(a6)
  93.  
  94. * Free command
  95.     move.l    d4,a1
  96.     move.l    d5,d0
  97.     jsr    _LVOFreeMem(a6)
  98.  
  99.     movem.l    (a7)+,d2-d5/a2-a5
  100.     rts
  101.  
  102. notags    dc.l    TAG_DONE
  103.  
  104. __child_startup_end:
  105.  
  106.     end
  107.